-
-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not immediately fail if git is not available #1074
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About testing, you can obtain the git interpreter through plumbum.local["git"]
instead. That'll be easier to mock.
https://plumbum.readthedocs.io/en/latest/local_commands.html#guide-local-commands
This is ready for a second pass. I think now it will be easier to test (haven't started doing it yet). On the other hand, my other question still stands:
|
I don't think this is a good solution. Instead, those functions should be able to return a boolean without relying in the presence of git. That shouldn't be too hard (just check if there's a This way, if it really is a git repo and git is not available, then copier should fail. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1074 +/- ##
=======================================
Coverage 97.07% 97.08%
=======================================
Files 48 48
Lines 4143 4149 +6
=======================================
+ Hits 4022 4028 +6
Misses 121 121
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
63c635f
to
0339e7c
Compare
0339e7c
to
b5130c7
Compare
Applied changes and ran |
I'm reverting the corresponding commit for now |
b5130c7
to
d1b0b45
Compare
Apologies if this is not the right place to bring it up, but after this merge, I am still seeing a failure when attempting to run
|
See #1074 (comment), left it out of this PR |
Fix gh-312.
There are several ways of doing this, I picked one that I considered simple enough. The idea is to always import
git
from a centralized place, and in that place do a soft fail ifgit
fails to be imported fromplumbum.cmd
.This is how
copier --version
looks like with these changes:On the other hand, I made
copier.vcs.is_git_bundle
more consistent withis_git_shallow_repo
andis_in_git_repo
, and now it returnsFalse
if there is anOSError
orProcessExecutionError
error. Thanks to that, now copier can work with gitless templates as well, as mentioned in #1045 (comment):I have two questions:
plumbum.cmd.git
is not an actual attribute, things are more complicated:I could do a very deep patching of how
plumbum.local
retrieves the command, but wanted to ask for advice first.copier.vcs.is_git_bundle
,is_git_shallow_repo
, andis_in_git_repo
should return None or something else thanTrue
orFalse
, if the git status could not be determined because the git command is missing. In this scheme, returningNone
would mean "I don't know if this directory is actually a git repo". For this reason, I preferred to wait before proceeding any further adding tests.Let me know what you folks think.
For the record, I too was a bit puzzled by the heavyweight requirements to run the linter #931 so going forward I think I'll use Gitpod to continue this PR (I have only used Nix a bit when experimenting with Replit earlier this year, not sure if I already want to commit to installing it on my home laptop).